#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

struct window {
	int r1, s1, r2, s2;
	vector<int> block;
};

window w[105];

set<int> ans;
bool vis[105];

void add(int x) {
	if (vis[x]) return;
	vis[x] = 1;
	ans.insert(x);
	for (int i = 0; i < w[x].block.size(); ++i) {
		add(w[x].block[i]);
	}
}

int main() {
	int n, r1, r2, s1, s2;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d %d %d", &w[i].r1, &w[i].s1, &w[i].r2, &w[i].s2);
	}

	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			if (w[j].r1 <= w[i].r1 && w[i].r1 <= w[j].r2 && w[j].s1 <= w[i].s2 && w[i].s2 <= w[j].s2) {
				//printf("%d <-- %d\n", i, j);
				w[i].block.push_back(j);
			}
		}
	}

	add(1);
	printf("%d\n", ans.size());
	return 0;
}